package com.atstudy.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2023/2/1 13:38
 * @copyright: 博为峰
 */
//@WebServlet(urlPatterns = {"/sn"}, name = "sn", loadOnStartup = 1)
//@WebServlet(urlPatterns = "/sn")
//@WebServlet(value = "/sn")
@WebServlet("/sn")
public class SessionServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        HttpSession session = req.getSession();
//        session.invalidate();//销毁
//        session.isNew();//是否新session对象
        System.out.println("session = " + session);

        Cookie cookie = new Cookie("bwf", "com.atstudy");
        resp.addCookie(cookie);
    }
}
